home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #12 / Amiga Plus CD - 2002 - No. 12.iso / Tools / Freeware / PerfectPaint / rexx / general / SaveAnimGif.rx < prev    next >
Encoding:
Text File  |  2001-12-23  |  3.4 KB  |  205 lines

  1. /*     arexx Script 
  2.     SAVE Anim in GIF format
  3.     need in 'PerfectPaint/tools':
  4.     - tapgif
  5.     - WhirlGif
  6. */
  7.  
  8.     options results
  9.     parse ARG Port b
  10.     
  11.     ADDRESS value Port
  12.        options results
  13.  
  14.     pp_CountFrames
  15.     nb=result
  16.     if nb<2 then do
  17.         pp_Warn 'Make*an*Anim*first.'
  18.         EXIT
  19.     end
  20.  
  21.     file=""
  22.     file2=""
  23.     option=0
  24.     option2=0
  25.     if EXISTS('PerfectPaint:Prefs/Rexx_Prefs/SaveAnimGif') THEN DO
  26.         IF OPEN('lfile','PerfectPaint:Prefs/Rexx_Prefs/SaveAnimGif', "R") then DO
  27.             file = READLN('lfile')
  28.             option=READLN('lfile')
  29.             option2=READLN('lfile')
  30.             CALL CLOSE('lfile')
  31.             file2=""
  32.             do i=1 to LENGTH(file)
  33.                 a=SUBSTR(file,i,1)
  34.                 if a=" " then DO
  35.                     a="*"
  36.                 END
  37.                 file2=file2||a
  38.             END
  39.             file=file2
  40.         END
  41.     END
  42.  
  43.     pp_GetDepth
  44.     D=result
  45.     IF D=24 then DO
  46.         pp_RenderReq 1
  47.     END
  48.  
  49.     pp_DialogInit 250 100 "*Save*AnimGif*" 4
  50.         pp_String 0 55 8 150 16 "Name" 1 100 file
  51.  
  52.         n=LASTPOS('/',file)
  53.         if n=0 then DO
  54.             n=LASTPOS(':',file)
  55.             file=SUBSTR(file,1,n)
  56.         END
  57.         else DO            
  58.             file=SUBSTR(file,1,n)
  59.         END
  60.  
  61.         pp_Getfile 1 210 9 0 "Save*AnimGif" 0 file
  62.         pp_Cycle 2 105 28 100 16 "Transparency" 1 "No|Color*0|Current*Bg" option
  63.         pp_Cycle 3 105 48 100 16 "Disposal*method" 1 "None|Not|Background|Previous" option2
  64.     pp_Dialog        
  65.  
  66.     rc=result
  67.     if rc=0 then
  68.         do
  69.             EXIT
  70.         end    
  71.  
  72.     pp_GetDialog 0
  73.     file=result
  74.     IF file="" then DO
  75.         EXIT
  76.     END
  77.  
  78.     file2='PerfectPaint:temp/temp'
  79.  
  80.     pp_GetDialog 2
  81.     option=result
  82.  
  83.     pp_GetDialog 3
  84.     option2=result
  85.  
  86.     CALL SavePrefs('SaveAnimGif',file,option,option2)
  87.     ADDRESS value Port
  88.  
  89.     if option2=0 then
  90.     DO
  91.     dispose='none'
  92.     END
  93.  
  94.     if option2=1 then
  95.     DO
  96.     dispose='not'
  97.     END
  98.  
  99.     if option2=2 then
  100.     DO
  101.     dispose='back'
  102.     END
  103.  
  104.     if option2=3 then
  105.     DO
  106.     dispose='prev'
  107.     END
  108.  
  109.     if option=2 then
  110.     DO
  111.         pp_GetBpen
  112.         Bpen=result
  113.     END
  114.  
  115.     if option=1 then
  116.     DO
  117.         Bpen=0
  118.     END
  119.  
  120.     pp_GotoFrame 1
  121.     pp_GetJiffies
  122.     jiffies=result*2
  123.     filetemp="ram:temp"
  124.  
  125.     ii=''
  126.     IF D=24 then DO
  127.         pp_Render 2 'PerfectPaint:Temp/temp'
  128.         CALL OPEN(out,filetemp,write)
  129.         pp_asay 'Making*GIF*picture|Please*wait*...'
  130.         Do i=1 to nb
  131.             ii=i
  132.             IF i<100 then DO
  133.                 ii='0'||i
  134.                 IF i<10 then DO
  135.                     ii='00'||i
  136.                 END
  137.             END
  138.             address COMMAND
  139.             'perfectpaint:tools/tapgif '||'PerfectPaint:Temp/temp'||ii||' '||'PerfectPaint:Temp/temp.'||ii
  140.             CALL WRITELN(out,'PerfectPaint:Temp/temp.'||ii)                        
  141.         END    
  142.         ADDRESS value Port
  143.         pp_CloseAsay
  144.     END
  145.  
  146.     IF D<24 then DO
  147.         pp_asay 'Saving*GIF*file|Please*wait*...'
  148.         CALL OPEN(out,filetemp,write)
  149.         DO i=1 to nb
  150.             pp_GotoFrame i    
  151.             pp_save 't:pptemp' 0
  152.             file3=file2||i
  153.             address COMMAND
  154.             'perfectpaint:tools/tapgif '||'t:pptemp '||'"'||file3||'"'
  155.             'delete >nil: t:pptemp'
  156.             CALL WRITELN(out,file3)
  157.             ADDRESS value Port
  158.         END        
  159.         pp_CloseAsay
  160.     END
  161.  
  162.     pp_asay 'Making*Animation|Please*wait*...'
  163.  
  164.     address COMMAND
  165.     CALL CLOSE(out)
  166.  
  167.     if option=0 then
  168.     DO
  169.     'perfectpaint:tools/WhirlGif -time '||jiffies||' -o '||'"'||file||'"'||' -loop '||'-disp '||dispose||' -i ram:temp'    
  170.     END
  171.     ELSE
  172.     DO
  173.     'perfectpaint:tools/WhirlGif -time '||jiffies||' -o '||'"'||file||'"'||' -loop -trans '||Bpen||' -disp '||dispose||' -i ram:temp'
  174.     END
  175.     'delete >nil: PerfectPaint:Temp/?#.*'
  176.  
  177.     ADDRESS value Port
  178.     pp_SaveIconFor file 2
  179.     pp_CloseAsay
  180.  
  181.     address COMMAND
  182.     'delete >nil: ram:temp'
  183.  
  184.     EXIT
  185.     
  186.  
  187.  
  188. SavePrefs: PROCEDURE
  189.     
  190.     Prefname='PerfectPaint:Prefs/Rexx_Prefs/'||ARG(1)
  191.  
  192.     if EXISTS(Prefname) THEN DO
  193.         ADDRESS COMMAND
  194.         'delete >nil: '||Prefname
  195.     END
  196.  
  197.     IF OPEN('pfile',PrefName,'W') THEN DO
  198.  
  199.     do i=2 to ARG()
  200.         CALL WRITELN('pfile',ARG(i))
  201.     end
  202.  
  203.     CALL CLOSE('pfile')
  204.  
  205. RETURN